package com.cn.serverline.lineicp.workshopPlan.controller;


import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cn.serverline.lineicp.workshopPlan.entity.SparePartsType;
import com.cn.serverline.lineicp.workshopPlan.entity.TypesOfConsumables;
import com.cn.serverline.lineicp.workshopPlan.entity.request.SparePartsRequest;
import com.cn.serverline.lineicp.workshopPlan.entity.request.TypesOfConsumablesRequest;
import com.cn.serverline.lineicp.workshopPlan.service.SparePartsService;
import com.cn.serverline.lineicp.workshopPlan.service.TypesOfConsumablesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 耗材类型控制层
 *
 * @author 田江余
 * @date 2024年7月29日
 */
@Api(tags = "耗材类型")
@RestController
@ApiResource(name = "耗材类型")
public class TypesOfConsumablesController {

    @Resource(name = "typesOfConsumablesServiceImpl")
    private TypesOfConsumablesService typesOfConsumablesService;

    /**
     * 添加
     *
     * @author 田江余
     * @date 2024年7月29日
     */
    @ApiOperation(value = "添加耗材类型")
    @PostResource(name = "添加", path = "/typesOfConsumables/add")
    public ResponseData<?> add(@RequestBody @Validated TypesOfConsumablesRequest typesOfConsumablesRequest) {
        return new SuccessResponseData<>(typesOfConsumablesService.add(typesOfConsumablesRequest));
    }

    /**
     * 删除
     *
     * @author 田江余
     * @date 2024年7月29日
     */
    @ApiOperation(value = "删除耗材类型")
    @PostResource(name = "删除", path = "/typesOfConsumables/delete")
    public ResponseData<?> delete(@RequestBody @Validated(SparePartsRequest.delete.class) TypesOfConsumablesRequest typesOfConsumablesRequest) {
        typesOfConsumablesService.del(typesOfConsumablesRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 编辑
     *
     * @author 田江余
     * @date 2024年7月29日
     */
    @ApiOperation(value = "编辑耗材类型")
    @PostResource(name = "编辑", path = "/typesOfConsumables/edit")
    public ResponseData<?> edit(@RequestBody @Validated(SparePartsRequest.edit.class) TypesOfConsumablesRequest typesOfConsumablesRequest) {
        typesOfConsumablesService.edit(typesOfConsumablesRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 获取列表
     *
     * @author 田江余
     * @date 2024年7月29日
     */
    @ApiOperation(value = "查询耗材类型")
    @GetResource(name = "获取列表", path = "/typesOfConsumables/list")
    public ResponseData<Page<TypesOfConsumables>> list(TypesOfConsumablesRequest typesOfConsumablesRequest) {
        return new SuccessResponseData<>(typesOfConsumablesService.findList(typesOfConsumablesRequest));
    }

}
